# import manage
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
#财务
class Finance(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    income = db.Column(db.Integer)
    off = db.Column(db.Integer)
    mark = db.Column(db.Boolean,default=True)
    def __init__(self,income,off,mark):
        self.income= income
        self.off = off
        self.mark = mark

#学员
class Student(db.Model):
    id =db.Column(db.Integer,primary_key=True)
    local = db.Column(db.String(20))
    age = db.Column(db.Integer)
    laiyuan = db.Column(db.String(20))
    def __init__(self,local,age,laiyuan):
        self.local =local
        self.age =age
        self.laiyuan=laiyuan
def convert_list1(student):
    return dict(
        id =student.id,
        local = student.local,
        age = student.age,
        laiyuan = student.laiyuan
    )

#学员信息
class StudentInfo(db.Model):
    __tablename__='student_info'
    id = db.Column(db.Integer, primary_key=True)
    name =db.Column(db.String(20))
    sex =db.Column(db.String(10))
    id_card =db.Column(db.Integer)
    local =db.Column(db.String(20))
    wechat = db.Column(db.String(20))
    work =db.Column(db.String(20))
    def __init__(self,name,sex,id_card,local,wechat,work):
        self.name =name
        self.sex =sex
        self.id_card=id_card
        self.local =local
        self.wechat=wechat
        self.work =work
def convert_list2(stuinfo):
    return dict(
        id =stuinfo.id,
        name =stuinfo.name,
        sex =stuinfo.sex,
        id_card=stuinfo.id_card,
        local =stuinfo.local,
        wechat =stuinfo.wechat,
        work =stuinfo.work

    )

#业务类型
class Work(db.Model):
    id =db.Column(db.Integer,primary_key=True)
    jineng = db.Column(db.String(20),unique=True)
    xueli = db.Column(db.String(20),unique=True)
    kaozheng = db.Column(db.String(20),unique=True)
    def __init__(self,jineng,xueli,kaozheng):
        self.jineng =jineng
        self.xueli =xueli
        self.kaozheng =kaozheng
def convert_list3(work):
    return dict(
        id = work.id,
        jineng = work.jineng,
        xueli = work.xueli,
        kaozheng = work.kaozheng
    )

#就业信息
class Employment(db.Model):
    id =db.Column(db.Integer,primary_key=True)
    name = db.Column(db.String(20))
    phone = db.Column(db.Integer,unique=True)
    wechat = db.Column(db.String(20),unique=True)
    salary=db.Column(db.Integer)
    company =db.Column(db.String(20))
    place=db.Column(db.String(20))
    gradu_time=db.Column(db.String(20))
    work_time=db.Column(db.String(20))
    def __init__(self,name,phone,wechat,salary,company,place,gradu_time,work_time):
        self.name =name
        self.phone= phone
        self.wechat =wechat
        self.salary =salary
        self.company =company
        self.place =place
        self.gradu_time =gradu_time
        self.work_time =work_time

def convert_list4(employment):
    return dict(
        id =employment.id,
        name = employment.name,
        phone = employment.phone,
        wechat = employment.wechat,
        salaray=employment.salary,
        company =employment.company,
        place =employment.place,
        gradu_time =employment.gradu_time,
        work_time =employment.work_time
    )

# 生源统计
class Statistics(db.Model):
# # 建立函数字段
    id = db.Column(db.Integer, primary_key=True)
    teacher_intr = db.Column(db.String(20))
    trainess_intr = db.Column(db.String(20))
    agent_intr = db.Column(db.String(20))
    def __init__(self,teacher_intr,trainess_intr,agent_intr,mark=1):
        self.teacher_intr = teacher_intr
        self.trainess_intr = trainess_intr
        self.agent_intr = agent_intr
        self.mark = mark

def con1(ses):
    return dict(
        id = ses.id,
        teacher_intr = ses.teacher_intr,
        trainess_intr = ses.trainess_intr,
        agent_intr = ses.agent_intr
    )

# 企业考证
class Enterprise(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    enterprise_name = db.Column(db.String(20))
    contact_person = db.Column(db.Integer)
    contact_number = db.Column(db.Integer)
    invoice_title = db.Column(db.String(20))
    invoice_number = db.Column(db.Integer)
    certificate = db.Column(db.String(20))
    sector = db.Column(db.String(20))
    number_persons = db.Column(db.Integer)
    price = db.Column(db.Integer)
    feedback = db.Column(db.Integer)
    time = db.Column(db.String(20))
    remarks = db.Column(db.String(20))

    def __init__(self,
                 enterprise_name,
                 contact_person,
                 contact_number,
                 invoice_title,
                 invoice_number,
                 certificate,
                 sector,
                 number_persons,
                 price,
                 feedback,
                 time,
                 remarks
                 ):
        self.enterprise_name = enterprise_name
        self.contact_person = contact_person
        self.contact_number = contact_number
        self.invoice_title = invoice_title
        self.invoice_number = invoice_number
        self.certificate = certificate
        self.sector = sector
        self.number_persons = number_persons
        self.price = price
        self.feedback = feedback
        self.time = time
        self.remarks = remarks


def con2(a):
    return dict(
        id=a.id,
        enterprise_name=a.enterprise_name,
        contact_person=a.contact_person,
        contact_number=a.contact_number,
        invoice_title=a.invoice_title,
        invoice_number=a.invoice_number,
        certificate=a.certificate,
        sector=a.sector,
        number_persons=a.number_persons,
        price=a.price,
        feedback=a.feedback,
        time=a.time,
        remarks=a.remarks
    )
# 校企合作
class School(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    enterprise_name = db.Column(db.String(20))
    contact_person = db.Column(db.String(20))
    telephone_number = db.Column(db.Integer)
    graduation_people = db.Column(db.Integer)
    return_money = db.Column(db.Float)
    receipt_day = db.Column(db.String(20))

    def __init__(self, enterprise_name, contact_person, telephone_number, graduation_people, return_money, receipt_day):
        self.enterprise_name = enterprise_name
        self.contact_person = contact_person
        self.telephone_number = telephone_number
        self.graduation_people = graduation_people
        self.return_money = return_money
        self.receipt_day = receipt_day


def con3(en):
    return dict(
        id=en.id,
        enterprise_name=en.enterprise_name,
        contact_person=en.contact_person,
        telephone_number=en.telephone_number,
        graduation_people=en.graduation_people,
        return_money=en.return_money,
        receipt_day=en.receipt_day
    )

# 采购管理
class Procurement(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), unique=True)
    number = db.Column(db.Integer)
    time = db.Column(db.Integer)
    company = db.Column(db.String(80))
    contact_person = db.Column(db.String(80))
    telephone_number = db.Column(db.Integer)
    amount_payable = db.Column(db.Float)
    paid_amount = db.Column(db.Float)

    def __init__(self, name, number, time, company, contact_person, telephone_number, amount_payable, paid_amount):
        self.name = name
        self.number = number
        self.time = time
        self.company = company
        self.contact_person = contact_person
        self.telephone_number = telephone_number
        self.amount_payable = telephone_number
        self.paid_amount = paid_amount


def con4(sen):
    return dict(
        id=sen.id,
        name=sen.name,
        number=sen.number,
        time=sen.time,
        company=sen.company,
        contact_person=sen.contact_person,
        telephone_number=sen.telephone_number,
        amount_payable=sen.amount_payable,
        paid_amount=sen.paid_amount
    )


# 学校收入
class School_Income(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    time = db.Column(db.String(50))
    study_textual_research_name = db.Column(db.String(20))
    phone = db.Column(db.Integer)
    wechat = db.Column(db.String(20))
    all_in_cost = db.Column(db.Integer)
    real_pay = db.Column(db.Integer)
    not_pay = db.Column(db.Integer)
    discounts = db.Column(db.Integer)
    travelling_expenses = db.Column(db.Integer)
    Payment_of_fees = db.Column(db.Integer)
    Paymeng_method = db.Column(db.String(20))
    Internal_business = db.Column(db.String(20))
    source = db.Column(db.String(20))
    remarks = db.Column(db.String(20))

    def __init__(self, time, study_textual_research_name, phone, wechat, all_in_cost, real_pay, not_pay, discounts,
                 travelling_expenses, Payment_of_fees, Paymeng_method, Internal_business, source, remarks):
        self.time = time
        self.study_textual_research_name = study_textual_research_name
        self.phone = phone
        self.wechat = wechat
        self.all_in_cost = all_in_cost
        self.real_pay = real_pay
        self.not_pay = not_pay
        self.discounts = discounts
        self.travelling_expenses = travelling_expenses
        self.Payment_of_fees = Payment_of_fees
        self.Paymeng_method = Paymeng_method
        self.Internal_business = Internal_business
        self.source = source
        self.remarks = remarks


def con5(select):
    return dict(
        id=select.id,
        time=select.time,
        study_textual_research_name=select.study_textual_research_name,
        phone=select.phone,
        wechat=select.wechat,
        all_in_cost=select.all_in_cost,
        real_pay=select.real_pay,
        not_pay=select.not_pay,
        discounts=select.discounts,
        travelling_expenses=select.travelling_expenses,
        Payment_of_fees=select.Payment_of_fees,
        Paymeng_method=select.Paymeng_method,
        Internal_business=select.Internal_business,
        source=select.source,
        remarks=select.remarks
    )

# 学校支出
class School_Expend(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    time = db.Column(db.String(50))
    use = db.Column(db.String(20))
    Payment_Object = db.Column(db.String(10))
    Agent = db.Column(db.String(12))
    Approver = db.Column(db.String(12))
    Cost = db.Column(db.Integer)
    Expenditure_Patterns = db.Column(db.String(12))
    Collection_Objects = db.Column(db.String(12))
    Number = db.Column(db.Integer)
    Petty_Cash = db.Column(db.Integer)
    Remarks = db.Column(db.String(20))

    # 初始化对象
    def __init__(self, time, use, Payment_Object, Agent, Approver, Cost, Expenditure_Patterns, Collection_Objects,
                 Number, Petty_Cash, Remarks):
        self.time = time
        self.use = use
        self.Payment_Object = Payment_Object
        self.Agent = Agent
        self.Approver = Approver
        self.Cost = Cost
        self.Expenditure_Patterns = Expenditure_Patterns
        self.Collection_Objects = Collection_Objects
        self.Number = Number
        self.Petty_Cash = Petty_Cash
        self.Remarks = Remarks


def con6(select):
    return dict(
        id=select.id,
        time=select.time,
        use=select.use,
        Payment_Object=select.Payment_Object,
        Agent=select.Agent,
        Approver=select.Approver,
        Cost=select.Cost,
        Expenditure_Patterns=select.Expenditure_Patterns,
        Collection_Objects=select.Collection_Objects,
        Number=select.Number,
        Petty_Cash=select.Petty_Cash,
        Remarks=select.Remarks

    )

# 手机号充值
class Phone_Up(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    time = db.Column(db.String(50))
    Top_up_object = db.Column(db.String(32))
    Phone = db.Column(db.Integer)
    Agent = db.Column(db.String(32))
    Approver = db.Column(db.String(32))
    Money = db.Column(db.Integer)
    Top_up_way = db.Column(db.String(32))
    cds = db.Column(db.Integer)

    # 初始化对象
    def __init__(self, time, Top_up_object, Phone, Agent, Approver, Money, Top_up_way, cds):
        self.time = time
        self.Top_up_object = Top_up_object
        self.Phone = Phone
        self.Agent = Agent
        self.Approver = Approver
        self.Money = Money
        self.Top_up_way = Top_up_way
        self.cds = cds


def con7(select):
    return dict(
        id=select.id,
        time=select.time,
        Top_up_object=select.Top_up_object,
        Phone=select.Phone,
        Agent=select.Agent,
        Approver=select.Approver,
        Money=select.Money,
        Top_up_way=select.Top_up_way,
        cds=select.cds
    )


# 学历部支出
class EduOff(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    time = db.Column(db.String(20))
    usewhere = db.Column(db.String(20))
    offobject = db.Column(db.String(20))
    people_make = db.Column(db.String(20))
    people_check = db.Column(db.String(20))
    money = db.Column(db.Integer)
    off_style = db.Column(db.String(20))
    getobject = db.Column(db.String(20))
    number = db.Column(db.Integer)
    beizhu = db.Column(db.String(20))

    def __init__(self, time, usewhere, offobject, people_make, people_check, money, off_style, getobject, number,
                 beizhu):
        self.time = time
        self.usewhere = usewhere
        self.offobject = offobject
        self.people_make = people_make
        self.people_check = people_check
        self.money = money
        self.off_style = off_style
        self.getobject = getobject
        self.number = number
        self.beizhu = beizhu


def con8(eduoff):
    return dict(
        id=eduoff.id,
        time=eduoff.time,
        usewhere=eduoff.usewhere,
        offobject=eduoff.offobject,
        people_make=eduoff.people_make,
        people_check=eduoff.people_check,
        money=eduoff.money,
        off_style=eduoff.off_style,
        getobject=eduoff.getobject,
        number=eduoff.number,
        beizhu=eduoff.beizhu
    )

# 学历部收入
class EduGet(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    time = db.Column(db.String(20))
    usewhere = db.Column(db.String(20))
    payobject = db.Column(db.String(20))
    people_get = db.Column(db.String(20))
    real_money = db.Column(db.Integer)
    none_money = db.Column(db.Integer)
    discount = db.Column(db.Integer)
    off_style = db.Column(db.String(20))
    beizhu = db.Column(db.String(20))

    def __init__(self, time, usewhere, payobject, people_get, real_money, none_money, discount, off_style, beizhu):
        self.time = time
        self.usewhere = usewhere
        self.payobject = payobject
        self.people_get = people_get
        self.real_money = real_money
        self.none_money = none_money
        self.discount = discount
        self.off_style = off_style
        self.beizhu = beizhu


def con9(eduget):
    return dict(
        id=eduget.id,
        time=eduget.time,
        usewhere=eduget.usewhere,
        payobject=eduget.payobject,
        people_get=eduget.people_get,
        real_money=eduget.real_money,
        none_money=eduget.none_money,
        discount=eduget.discount,
        off_style=eduget.off_style,
        beizhu=eduget.beizhu
    )
